package string.related;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class TimeStampToData {

	public static void main(String[] args) {
		// toDay();
		// toDay2();
		getSubString();
	}

	private static void getSubString() {
		String d = "/Date(1444643212742)/";
		d = d.substring(6, d.length() - 2);
		String date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.CHINA).format(new java.util.Date(Long
				.valueOf(d)));
		System.out.println(d);
		System.out.println(date);

	}

	private static void toDay() {
		Long stamp = System.currentTimeMillis();
		String date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.CHINA).format(new java.util.Date(Long
				.valueOf(stamp) * 1000));
		System.out.println(date);

	}

	private static void toDay2() {
		Date date = new Date();
		System.out.println(date); // Fri Jul 11 15:49:56 CST 2014

		DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		String dateNow = df.format(date);
		System.out.println(dateNow); // 2014-07-11 03:49:56

		System.out.println("df.format(date) = " + df.format(date)); // 2014-07-11
																	// 03:49:56

		DateFormat df2 = DateFormat.getDateInstance();
		System.out.println("DateFormat.getDateInstance().format(new Date()) = " + df2.format(new Date()));
	}

}
